package jp.ac.nitech.matlab.najm.io;

import java.io.File;
import java.io.PrintWriter;

/**
 * <[  بسم الله الرحمان الرحيم  ]
 * @author k-hon
 *
 */
public class FileTrace implements Trace{
	
	File target;
	PrintWriter printer;
	
	public FileTrace(File letarget)throws Exception{
		this.target = letarget;
		printer = new PrintWriter(target);
	}
	
	public void info(Object src, int id, String msg){
		info(src, "["+id+"]:: "+msg);
	}
	public void info(Object src, String msg){
		printer.println("INFO__"+src.getClass().getName()+" : "+msg);
		printer.flush();
	}
	
	public void error(Object src, String msg){
		printer.println("ERR__"+src.getClass().getName()+" : "+msg);
		printer.flush();
	}
	
	public void error(Object src, Exception ex){
		printer.println("ERR__"+src.getClass().getName()+" : "+ex.getMessage());
		ex.printStackTrace(printer);
		printer.flush();
	}
}
